#include "CameraParameters.h"

SMatrix4x4 SRawCameraParameters::CalculateProjectionMatrix() const
{
    //calculate projection matrix
    if(ProjectionType==EProjectionType::Perspective)
    {
        return SMatrix4x4::Perspective(
            PerspectiveFOVY,
            AspectRatio,
            Near,
            Far
        );
    }
    else
    {
        
        float OrthoHeight=OrthographicWidth/AspectRatio;
        return SMatrix4x4::Orthographic(
            -OrthographicWidth*0.5f,
            OrthographicWidth*0.5f,
            -OrthoHeight*0.5f,
            OrthoHeight*0.5f,
            Near,
            Far
        );

    }    
}

SMatrix4x4 SRawCameraParameters::CalculateViewMatrix() const
{
    return SMatrix4x4::LookAt(
        ViewportPosition,
        ViewportRotation.GetForwardDirection(),
        ViewportRotation.GetUpDirection()
    );
}